package com.dmap.analysispoint.service.impl;

import com.dmap.analysispoint.bo.CompanyInfoBo;
import com.dmap.analysispoint.constants.BurialPointConstant;
import com.dmap.analysispoint.rpc.RpcCompanyInfoService;
import com.dmap.analysispoint.service.GetCompanyIdService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * \* @author:zhouhao
 * \* Date:15/06/2018
 * \* Description:
 * \*
 */
@Service
public class GetCompanyIdServiceImpl implements GetCompanyIdService {

    @Resource
    private RpcCompanyInfoService rpcCompanyInfoService;

    /**
     *
     * @param projectId String projectId;       项目编号（APP编号）
     *
     * @return companyId                  公司id
     */
    @Override
    public Long getCompanyIdByProjectId(String projectId) {
        CompanyInfoBo companyInfoBo = rpcCompanyInfoService.selectByProjectId(projectId);
        long companyId;
        if(StringUtils.isBlank(companyInfoBo.getId())) {
            companyId = BurialPointConstant.COMPANY_ID;
        }else {
            companyId = Long.parseLong(companyInfoBo.getId());
        }
        return companyId;
    }
}
